package com.sdy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sdy.entity.Student;
import com.sdy.mapper.StudentMapper;
import com.sdy.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: ssm-sm
 * @author: sdy
 * @create: 2022-12-06 14:09
 **/
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;


    @Override
    public PageInfo<Student> showAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Student> students = studentMapper.showAll();
        PageInfo<Student> studentPageInfo = new PageInfo<Student>(students);
        return studentPageInfo;
    }

    @Override
    public int delStu(int sid) {
        int i = studentMapper.delStu(sid);
        return i;
    }

    @Override
    public int addStu(Student student) {
        int i = studentMapper.addStu(student);
        return i;
    }

    @Override
    public Student queryStudentById(int sid) {
        Student student = studentMapper.SelectStudentByid(sid);
        return student;
    }

    @Override
    public int updStu(Student student) {
        int i = studentMapper.updStu(student);
        return i;
    }
}
